package Interpreter;

public class Client {
    public static void main(String[] args) {
        Context context = new Context();
        Variable a = new Variable("a");
        Variable b = new Variable("b");
        Variable c = new Variable("c");
        Variable d = new Variable("d");

        context.put(a,1);
        context.put(b,2);
        context.put(c,3);
        context.put(d,4);

        //获取抽象语法树   例如表达式为：a-(b-c)+d
        AbstractExpression expression = new Plus(new Minus(a,new Minus(b,c)),d);

        //解释（计算）
        int result = expression.interpret(context);
        System.out.println(expression+"="+result);
    }
}
